package com.Day10;

/**
 * @author: 若若叶
 * @date: 2021/7/18 14:09
 * FileName: MyNode
 * Description: 模拟链表的节点
 */

//这里为什么报错
import java.util.Objects;

/**
 * 链表的节点由两部分组成，一是数据，二是下一个节点的地址（这里相当于下一个节点）
 */
public class MyNode {
    private Object date;
    private MyNode next;

    public MyNode() {
    }

    public MyNode(Object date, MyNode next) {
        this.date = date;
        this.next = next;
    }

    public Object getDate() {
        return date;
    }

    public void setDate(Object date) {
        this.date = date;
    }

    public MyNode getNext() {
        return next;
    }

    public void setNext(MyNode next) {
        this.next = next;
    }

    @Override
    public String toString() {
        return "MyNode{" +
                "date=" + date +
                ", next=" + next +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        //if没有大括号也报错？这不是idea自己写的吗？？
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MyNode myNode = (MyNode) o;
        //????
        return Objects.equals(date, myNode.date) &&
                Objects.equals(next, myNode.next);
    }
}
